package com.source.springioc;

import com.source.springioc.domain.Student;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

/**
 * Created by tan on 2017/6/23.
 */
public class Main {
	public static void main(String[] args) {
		BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("spring.xml"));
		Student student = (Student) beanFactory.getBean("student");
		System.out.println(student.getName());

//		Teacher teacher =  beanFactory.getBean(Teacher.class);
//		System.out.println(teacher.getStudent().getName());

//		ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
//		Student student = (Student) applicationContext.getBean("student");
//		System.out.println(student.getName());
//
//		Teacher teacher =  (Teacher) applicationContext.getBean("teacher");
//		System.out.println(teacher.getStudent().getName());
	}
}
